package org.xiaodongwei.jvm.utils;

public class Log {
    private Log() {
        content = new StringBuilder();
    }

    private static Log instance;

    private StringBuilder content;

    public static Log getInstance() {
        if (instance == null) {
            synchronized (Log.class) {
                if (instance == null) {
                    instance = new Log();
                }
            }
        }
        return instance;
    }

    public Log clear() {
        content.delete(0, content.length());
        return this;
    }

    public Log setTag(String tag) {
        content.append(tag).append(": ");
        return this;
    }

    public Log param(String key, String value) {
        content.append("\n");
        content.append(key).append(":").append(value);
        content.append("; ");
        return this;
    }

    public void to() {
        System.out.println(content.toString());
    }
}
